package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.result.ListResult;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.SystemInitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:SystemInitController
 * @功能：系统初始
 * @author：wlei
 * @日期：2022/7/9-02:00
 **/
@RestController
@Slf4j
@RequestMapping("/v1/systeminit/")
public class SystemInitController extends BaseController {


    @Autowired
    private SystemInitService systemInitService;

    @Autowired
    private RabbitTemplate template;

    /**
     * 分页获取数据
     *
     * @return
     */
    @GetMapping("listByPage")
    public ListResult<Object> listByPage() {
        ListResult<Object> result = systemInitService.listByPage(getPageData());
        return result;
    }

    /**
     * 测试数据请求
     *
     * @return
     */
    @GetMapping("sayHi")
    public JsonObj sayHi() {
        PageData pageData = getPageData();
        String message = (String) pageData.get("message");
        JsonObj result = systemInitService.sayHi(message);
        return result;
    }

    /**
     * 数据插入演示
     *
     * @return
     */
    @PostMapping("execInsert")
    public JsonObj execInsert() {
        PageData pageData = getPageData();
        JsonObj result = systemInitService.execInsert(pageData);
        return result;
    }

    /**
     * 数据查询演示
     *
     * @return
     */
    @GetMapping("execSelect")
    public JsonObj execSelect() {
        PageData pageData = getPageData();
        //pageData.put("id", "1");
        JsonObj jsonObj = systemInitService.execSelect(pageData);
        return jsonObj;
    }

    /**
     * 分页获取测试数据
     *
     * @return
     */
    @GetMapping("testData")
    public ListResult<Object> testData() {
        return systemInitService.testData(getPageData());
    }
}
